#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
int main()
{
	int is_leap_year(int y);
	int get_days_of_month(int y, int x);
	int year = 0, month = 0;
	scanf("%d %d", &year, &month);
	int days = get_days_of_month(year, month);
	printf("%d\n", days);
	return 0;
}
int get_days_of_month(int y, int x)
{
	int days[] = { 0,31,28,31,30,31,30,31,31,30,31.30,31 };
	int day = days[x];
	if (is_leap_year(y) && x == 2)
		day += 1;
	return day;
}
int is_leap_year(int y)
{
	if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
		return 1;
	else
		return 0;
}